package com.hanrui.android.fragment.message.audit.proele;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hanrui.android.R;
import com.hanrui.android.activity.download.MyDownLoadActivity;
import com.hanrui.android.library.base.BaseFragment;
import com.hanrui.android.model.ProEleBidInfoDetailBean;
import com.hanrui.android.net.contract.message.audit.proele.ProEleBidInfoDetailContract;
import com.hanrui.android.net.presenter.message.audit.proele.ProEleBidInfoDetailPresenter;

import butterknife.BindView;

/**
 * 编标招标基本信息
 *
 */

public class ProEleBidInfoDetailFragment extends BaseFragment<ProEleBidInfoDetailPresenter> implements ProEleBidInfoDetailContract.View {
    @BindView(R.id.main_title)
    TextView mainTitle;
    @BindView(R.id.subhead_title)
    TextView subheadTitle;
    @BindView(R.id.name)
    TextView name;
    @BindView(R.id.thing_title)
    TextView thingTitle;
    @BindView(R.id.time)
    TextView time;
    @BindView(R.id.page_num)
    TextView pageNum;
    @BindView(R.id.duty_people)
    TextView dutyPeople;
    @BindView(R.id.copies_num)
    TextView copiesNum;
    @BindView(R.id.vote_meet)
    TextView voteMeet;
    @BindView(R.id.money_meet)
    TextView moneyMeet;
    @BindView(R.id.wind_meet)
    TextView windMeet;
    @BindView(R.id.receipt_num)
    TextView receiptNum;
    @BindView(R.id.receipt_page)
    TextView receiptPage;
    @BindView(R.id.batch_num)
    TextView batchNum;
    @BindView(R.id.is_akey)
    TextView isAkey;
    @BindView(R.id.measure_area)
    TextView measureArea;
    @BindView(R.id.collection_num)
    TextView collectionNum;
    @BindView(R.id.money_time)
    TextView moneyTime;
    @BindView(R.id.collection_time)
    TextView collectionTime;
    @BindView(R.id.transfer_time)
    TextView transferTime;
    @BindView(R.id.transfer_thing)
    TextView transferThing;
    @BindView(R.id.enclosure_ll1)
    LinearLayout enclosureLl1;
    @BindView(R.id.enclosure1)
    ImageView enclosure1;
    @BindView(R.id.enclosure_ll2)
    LinearLayout enclosureLl2;
    @BindView(R.id.enclosure2)
    ImageView enclosure2;
    @BindView(R.id.enclosure_ll3)
    LinearLayout enclosureLl3;
    @BindView(R.id.enclosure3)
    ImageView enclosure3;
    @BindView(R.id.enclosure_ll4)
    LinearLayout enclosureLl4;
    @BindView(R.id.enclosure4)
    ImageView enclosure4;
    @BindView(R.id.enclosure_ll5)
    LinearLayout enclosureLl5;
    @BindView(R.id.enclosure5)
    ImageView enclosure5;
    @BindView(R.id.zhaobiao_name)
    TextView zhaobiaoName;
    @BindView(R.id.zhaobiao_time)
    TextView zhaobiaoTime;
    @BindView(R.id.zhaobiao_user)
    TextView zhaobiaoUser;
    @BindView(R.id.zhaobiao_phone)
    TextView zhaobiaoPhone;
    @BindView(R.id.total)
    TextView total;
    @BindView(R.id.down_money)
    TextView downMoney;
    @BindView(R.id.collection_house)
    TextView collectionHouse;
    @BindView(R.id.rodline_transfer)
    TextView rodlineTransfer;
    @BindView(R.id.engineering_money)
    TextView engineeringMoney;
    @BindView(R.id.main_build)
    TextView mainBuild;
    @BindView(R.id.starttime)
    TextView starttime;
    @BindView(R.id.endtime)
    TextView endtime;
    @BindView(R.id.bianbiao_title)
    TextView bianbiaoLl;
    @BindView(R.id.ll_addview)
    LinearLayout lladdview;
    @BindView(R.id.design_company)
    TextView designCompany;
    @BindView(R.id.address_user)
    TextView addressUser;
    @BindView(R.id.address_phone)
    TextView addressPhone;
    @BindView(R.id.remarks)
    TextView remarks;
    @BindView(R.id.review_type)
    TextView reviewType;
    @BindView(R.id.subject_entry)
    TextView subjectEntry;
    @BindView(R.id.subject_main)
    TextView subjectMain;
    @BindView(R.id.person_charge)
    TextView personCharge;
    @BindView(R.id.party_a)
    TextView partyA;
    @BindView(R.id.shenji_title)
    TextView shenjiLl;
    @BindView(R.id.ll_addview2)
    LinearLayout lladdview2;
    @BindView(R.id.jointime)
    TextView jointime;
    @BindView(R.id.joinendtime)
    TextView joinendtime;
    @BindView(R.id.biao_num)
    TextView biaoNum;
    @BindView(R.id.biao_type)
    TextView biaoType;
    @BindView(R.id.biao_starttime)
    TextView biaoStarttime;
    @BindView(R.id.biao_require)
    TextView biaoRequire;
    @BindView(R.id.biao_remark)
    TextView biaoRemark;
    @BindView(R.id.enclosure_ll6)
    LinearLayout enclosureLl6;
    @BindView(R.id.enclosure6)
    ImageView enclosure6;
    @BindView(R.id.enclosure_ll7)
    LinearLayout enclosureLl7;
    @BindView(R.id.enclosure7)
    ImageView enclosure7;
    @BindView(R.id.enclosure_ll8)
    LinearLayout enclosureLl8;
    @BindView(R.id.enclosure8)
    ImageView enclosure8;
    @BindView(R.id.biao_remarks)
    TextView biaoRemarks;
    @BindView(R.id.enclosure_num1)
    TextView enclosureNum1;
    @BindView(R.id.enclosure_num2)
    TextView enclosureNum2;
    @BindView(R.id.enclosure_num3)
    TextView enclosureNum3;
    @BindView(R.id.enclosure_num4)
    TextView enclosureNum4;
    @BindView(R.id.enclosure_num5)
    TextView enclosureNum5;
    @BindView(R.id.enclosure_num6)
    TextView enclosureNum6;
    @BindView(R.id.enclosure_num7)
    TextView enclosureNum7;
    @BindView(R.id.enclosure_num8)
    TextView enclosureNum8;


    String taskId,procInsId,bizId;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_proelebidinfodetail;
    }

    @Override
    protected void initInjector() { mFragmentComponent.inject(this); }

    @Override
    protected void initView(View view) {

        taskId = getArguments().getString("taskId");
        procInsId = getArguments().getString("procInsId");
        bizId = getArguments().getString("bizId");

        mPresenter.proEleBidInfoBizDetail(getActivity(),taskId,procInsId,bizId);

    }



    public static ProEleBidInfoDetailFragment newInstance(String taskId, String procInsId, String bizId) {
        ProEleBidInfoDetailFragment fragment = new ProEleBidInfoDetailFragment();
        Bundle bundle = new Bundle();
        bundle.putString("taskId", taskId);
        bundle.putString("procInsId", procInsId);
        bundle.putString("bizId", bizId);
        fragment.setArguments(bundle);
        return fragment;
    }

    @Override
    public void proEleBidInfoBizDetail(final ProEleBidInfoDetailBean data) {

        if (null != data) {

            mainTitle.setText(data.getDetail().getName()+"的项目招标");
            name.setText(data.getDetail().getNo());
            thingTitle.setText(data.getDetail().getBusName());
            time.setText(data.getDetail().getContractEstPrice());
            pageNum.setText(data.getDetail().getBuildCompany());
            dutyPeople.setText(data.getDetail().getContactsName());
            copiesNum.setText(data.getDetail().getContactsPhone());
            voteMeet.setText(data.getDetail().getContent());
            moneyMeet.setText(data.getDetail().getName());
            windMeet.setText(data.getDetail().getType());
            receiptNum.setText(data.getDetail().getBidMode());
            receiptPage.setText(data.getDetail().getProType());
            batchNum.setText(data.getDetail().getSignTime());
            isAkey.setText(data.getDetail().getEstPrice());
            measureArea.setText(data.getDetail().getIsBt());
            collectionNum.setText(data.getDetail().getIsEleBid());
            moneyTime.setText(data.getDetail().getStandType());
            collectionTime.setText(data.getDetail().getStandTime());
            transferTime.setText(data.getDetail().getScale());
            transferThing.setText(data.getDetail().getDrawTime());

            if (null != data.getDetail().getFile1() && data.getDetail().getFile1().size() > 0) {

                enclosureLl1.setVisibility(View.VISIBLE);
                enclosureNum1.setText("["+data.getDetail().getFile1().size()+"]");
                enclosure1.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile1());
                    }
                });
            }

            if (null != data.getDetail().getFile2() && data.getDetail().getFile2().size() > 0) {

                enclosureLl2.setVisibility(View.VISIBLE);
                enclosureNum2.setText("["+data.getDetail().getFile2().size()+"]");
                enclosure2.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile2());
                    }
                });
            }


            if (null != data.getDetail().getFile3() && data.getDetail().getFile3().size() > 0) {

                enclosureLl3.setVisibility(View.VISIBLE);
                enclosureNum3.setText("["+data.getDetail().getFile3().size()+"]");
                enclosure3.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile3());
                    }
                });
            }

            if (null != data.getDetail().getFile4() && data.getDetail().getFile4().size() > 0) {

                enclosureLl4.setVisibility(View.VISIBLE);
                enclosureNum4.setText("["+data.getDetail().getFile4().size()+"]");
                enclosure4.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile4());
                    }
                });
            }


            if (null != data.getDetail().getFile5() && data.getDetail().getFile5().size() > 0) {

                enclosureLl5.setVisibility(View.VISIBLE);
                enclosureNum5.setText("["+data.getDetail().getFile5().size()+"]");
                enclosure5.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile5());
                    }
                });
            }

            zhaobiaoName.setText(data.getDetail().getTenderId());
            zhaobiaoTime.setText(data.getDetail().getTenderTime());
            zhaobiaoUser.setText(data.getDetail().getTenderName());
            zhaobiaoPhone.setText(data.getDetail().getTenderPhone());
            total.setText(data.getDetail().getBidName());
            downMoney.setText(data.getDetail().getBidTime());
            collectionHouse.setText(data.getDetail().getBidContractName());
            rodlineTransfer.setText(data.getDetail().getBidImplementName());
            engineeringMoney.setText(data.getDetail().getBidContractPhone());
            mainBuild.setText(data.getDetail().getBidImplementPhone());
            starttime.setText(data.getDetail().getBidPrice());
            endtime.setText(data.getDetail().getBidCost());

            if (null != data.getDetail().getBidList() && data.getDetail().getBidList().size() > 0) {

                bianbiaoLl.setVisibility(View.VISIBLE);
                lladdview.setVisibility(View.VISIBLE);
                for (int i = 0; i < data.getDetail().getBidList().size(); i++) {

                    addViewItem(data.getDetail().getBidList().get(i));
                }

            }

            designCompany.setText(data.getDetail().getAuditName());
            addressUser.setText(data.getDetail().getAuditProTime());
            addressPhone.setText(data.getDetail().getAuditContractName());
            remarks.setText(data.getDetail().getAuditContractPhone());
            reviewType.setText(data.getDetail().getAuditTime());
            subjectEntry.setText(data.getDetail().getAuditMember());
            subjectMain.setText(data.getDetail().getAuditPlace());
            personCharge.setText(data.getDetail().getAuditPrice());
            partyA.setText(data.getDetail().getAuditCost());

            if (null != data.getDetail().getAuditList() && data.getDetail().getAuditList().size() > 0) {

                shenjiLl.setVisibility(View.VISIBLE);
                lladdview2.setVisibility(View.VISIBLE);
                for (int i = 0; i < data.getDetail().getAuditList().size(); i++) {

                    addViewItem1(data.getDetail().getAuditList().get(i));
                }
            }

            jointime.setText(data.getDetail().getTenderStartTime());
            joinendtime.setText(data.getDetail().getTenderEndTime());
            biaoNum.setText(data.getDetail().getTenderNo());
            biaoType.setText(data.getDetail().getTenderAudType());
            biaoStarttime.setText(data.getDetail().getTenderOpenTime());
            biaoRequire.setText(data.getDetail().getTenderMemberReq());
            biaoRemark.setText(data.getDetail().getTenderMarks());
            biaoRemarks.setText(data.getDetail().getRemarks());


            if (null != data.getDetail().getFile6() && data.getDetail().getFile6().size() > 0) {

                enclosureLl6.setVisibility(View.VISIBLE);
                enclosureNum6.setText("["+data.getDetail().getFile6().size()+"]");
                enclosure6.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile6());
                    }
                });
            }


            if (null != data.getDetail().getFile7() && data.getDetail().getFile7().size() > 0) {

                enclosureLl7.setVisibility(View.VISIBLE);
                enclosureNum7.setText("["+data.getDetail().getFile7().size()+"]");
                enclosure7.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile7());
                    }
                });
            }

            if (null != data.getDetail().getFile8() && data.getDetail().getFile8().size() > 0) {

                enclosureLl8.setVisibility(View.VISIBLE);
                enclosureNum8.setText("["+data.getDetail().getFile8().size()+"]");
                enclosure8.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {

                        MyDownLoadActivity.start(getActivity(),data.getDetail().getFile8());
                    }
                });
            }
        }

    }



    //添加ViewItem
    private void addViewItem(ProEleBidInfoDetailBean.DetailBean.BidListBean bean) {
        View hotelEvaluateView = View.inflate(getActivity(), R.layout.item_bianbiao, null);
        TextView name = hotelEvaluateView.findViewById(R.id.name);
        TextView thingTitle = hotelEvaluateView.findViewById(R.id.thing_title);

        name.setText(bean.getName());
        thingTitle.setText(bean.getPrice());


        lladdview.addView(hotelEvaluateView);
    }


    //添加ViewItem
    private void addViewItem1(ProEleBidInfoDetailBean.DetailBean.AuditListBean bean) {
        View hotelEvaluateView = View.inflate(getActivity(), R.layout.item_shenji, null);
        TextView name = hotelEvaluateView.findViewById(R.id.name);
        TextView thingTitle = hotelEvaluateView.findViewById(R.id.thing_title);

        name.setText(bean.getName());
        thingTitle.setText(bean.getPrice());

        lladdview2.addView(hotelEvaluateView);
    }

}
